package com.dxs.demo.controller;

import cn.hutool.json.JSONUtil;
import com.dxs.demo.bean.pub.PublicEventBean;
import com.dxs.demo.bean.videoEvents.VideoShelter;
import com.dxs.demo.bean.videoEvents.intrusion.AreaIntrusion;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutorService;
import java.util.logging.Logger;


/**
 * @Classname VideoController
 * @Description TODO
 * @Date 2021/9/2 15:31
 * @Created by silence(dxs)
 */
@RestController
@RequestMapping("/videoEvent")

public class VideoController {
    @Autowired
    ExecutorService service;

    /**
     *  视频遮挡回调
     * @param
     * @return
     */
    @PostMapping("/videoShelter")
    public String videoShelter(@RequestBody PublicEventBean<VideoShelter> bean){
        service.submit(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println("视频遮挡回调:"+JSONUtil.parse(bean).toString());
        });
        System.out.println("main");

        return "success";
    }

    /**
     *  区域入侵回调
     * @param
     * @return
     */
    @PostMapping("/areaIntrusion")
    public String areaIntrusion(@RequestBody PublicEventBean<AreaIntrusion> bean){
        System.out.println("区域入侵回调:"+JSONUtil.parse(bean).toString());
        return "success";
    }


    /**
     *  越界侦测回调
     * @param
     * @return
     */
    @PostMapping("/areaCross")
    public String areaCross(@RequestBody PublicEventBean<AreaIntrusion> bean){
        System.out.println("越界侦测回调:"+JSONUtil.parse(bean).toString());
        return "success";
    }
}
